home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / src / oct-gperf.h < prev    next >
C/C++ Source or Header  |  1997-03-07  |  4KB  |  142 lines

  1. /* C code produced by gperf version 2.5 (GNU C++ version) */
  2. /* Command-line: gperf -a -C -E -H octave_kw_hash -g -N octave_kw_lookup -p -t octave.gperf  */
  3.  
  4. enum octave_kw_id
  5. {
  6.   all_va_args_kw,
  7.   break_kw,
  8.   case_kw,
  9.   catch_kw,
  10.   continue_kw,
  11.   else_kw,
  12.   elseif_kw,
  13.   end_kw,
  14.   end_try_catch_kw,
  15.   end_unwind_protect_kw,
  16.   endfor_kw,
  17.   endfunction_kw,
  18.   endif_kw,
  19.   endswitch_kw,
  20.   endwhile_kw,
  21.   for_kw,
  22.   function_kw,
  23.   global_kw,
  24.   gplot_kw,
  25.   gsplot_kw,
  26.   if_kw,
  27.   otherwise_kw,
  28.   replot_kw,
  29.   return_kw,
  30.   switch_kw,
  31.   try_kw,
  32.   unwind_protect_kw,
  33.   unwind_protect_cleanup_kw,
  34.   while_kw
  35. };
  36.  
  37. struct octave_kw { char *name; int tok; octave_kw_id kw_id; };
  38. /* maximum key range = 48, duplicates = 0 */
  39.  
  40. #ifdef __GNUC__
  41. inline
  42. #endif
  43. static unsigned int
  44. octave_kw_hash (register const char *str, register int len)
  45. {
  46.   static const unsigned char asso_values[] =
  47.     {
  48.      50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
  49.      50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
  50.      50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
  51.      50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
  52.      50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
  53.      50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
  54.      50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
  55.      50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
  56.      50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
  57.      50, 50, 50, 50, 50, 50, 50, 20,  5, 15,
  58.       0,  0,  0, 15, 15,  0, 50,  0,  5, 50,
  59.      28,  0,  0, 50, 10,  0, 25, 10, 50, 10,
  60.      50,  5, 50, 50, 50, 50, 50, 50,
  61.     };
  62.   return len + asso_values[str[len - 1]] + asso_values[str[0]];
  63. }
  64.  
  65. #ifdef __GNUC__
  66. inline
  67. #endif
  68. const struct octave_kw *
  69. octave_kw_lookup (register const char *str, register int len)
  70. {
  71.   enum
  72.     {
  73.       TOTAL_KEYWORDS = 29,
  74.       MIN_WORD_LENGTH = 2,
  75.       MAX_WORD_LENGTH = 22,
  76.       MIN_HASH_VALUE = 2,
  77.       MAX_HASH_VALUE = 49,
  78.     };
  79.  
  80.   static const struct octave_kw wordlist[] =
  81.     {
  82.       {"",}, {"",}, 
  83.       {"if",  IF, if_kw},
  84.       {"end",  END, end_kw},
  85.       {"else",  ELSE, else_kw},
  86.       {"endif",  END, endif_kw},
  87.       {"elseif",  ELSEIF, elseif_kw},
  88.       {"",}, 
  89.       {"endwhile",  END, endwhile_kw},
  90.       {"otherwise",  OTHERWISE, otherwise_kw},
  91.       {"break",  BREAK, break_kw},
  92.       {"",}, {"",}, 
  93.       {"for",  FOR, for_kw},
  94.       {"",}, 
  95.       {"while",  WHILE, while_kw},
  96.       {"endfor",  END, endfor_kw},
  97.       {"",}, {"",}, 
  98.       {"case",  CASE, case_kw},
  99.       {"",}, 
  100.       {"switch",  SWITCH, switch_kw},
  101.       {"",}, 
  102.       {"continue",  CONTINUE, continue_kw},
  103.       {"endswitch",  END, endswitch_kw},
  104.       {"",}, 
  105.       {"global",  GLOBAL, global_kw},
  106.       {"",}, 
  107.       {"end_try_catch",  END, end_try_catch_kw},
  108.       {"",}, {"",}, 
  109.       {"all_va_args",  ALL_VA_ARGS, all_va_args_kw},
  110.       {"unwind_protect_cleanup",  CLEANUP, unwind_protect_cleanup_kw},
  111.       {"try",  TRY, try_kw},
  112.       {"",}, 
  113.       {"catch",  CATCH, catch_kw},
  114.       {"function",  FCN, function_kw},
  115.       {"",}, {"",}, 
  116.       {"endfunction",  END, endfunction_kw},
  117.       {"",}, 
  118.       {"replot",  PLOT, replot_kw},
  119.       {"",}, 
  120.       {"end_unwind_protect",  END, end_unwind_protect_kw},
  121.       {"return",  FUNC_RET, return_kw},
  122.       {"gplot",  PLOT, gplot_kw},
  123.       {"gsplot",  PLOT, gsplot_kw},
  124.       {"",}, {"",}, 
  125.       {"unwind_protect",  UNWIND, unwind_protect_kw},
  126.     };
  127.  
  128.   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
  129.     {
  130.       register int key = octave_kw_hash (str, len);
  131.  
  132.       if (key <= MAX_HASH_VALUE && key >= 0)
  133.         {
  134.           register const char *s = wordlist[key].name;
  135.  
  136.           if (*s == *str && !strcmp (str + 1, s + 1))
  137.             return &wordlist[key];
  138.         }
  139.     }
  140.   return 0;
  141. }
  142.